<?php
echo posix_getpid();
$pid = pcntl_fork();
if ($pid==0){
    while (1){
        fprintf(STDOUT,"pid=%d child process do...\n",posix_getpid());
        sleep(2);
    }
}
while (1){
   $pid = pcntl_wait($status);
   fprintf(STDOUT,"exit pid=%d\n",$pid);
   if ($pid>0){
       if (pcntl_waitpid($status)){
           fprintf(STDOUT,"正常退出:exit pid=%d,exit-status=%d\n",$pid,pcntl_wexitstatus($status));
       }else if (pcntl_wifsignaled($status)){
           fprintf(STDOUT,"中断退出1:exit pid=%d,exit-status=%d\n",$pid,pcntl_wtermsig($status));
       }else if (pcntl_wifstopped($status)){
           fprintf(STDOUT,"中断退出2:exit pid=%d,SIGUM=%d\n",$pid,pcntl_wstopsig($status));
       }
   }
   fprintf(STDOUT,"pid=%d father process...\n",posix_getpid());
   sleep(3);
}